package com.bto.solar.work.vo;

import com.bto.solar.work.entity.User;
import com.bto.solar.work.utils.tree.ITree;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.List;


@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class UserVO extends User {

    private Company company;
    private List<Department> departmentList;
    private List<Permissions> permissionList;
    private List<Role> adminList;


    @Data
    @Accessors(chain = true)
    @NoArgsConstructor
    public static class Company implements Serializable {
        @JsonProperty("companyId")
        private Long companyId;
        @JsonProperty("name")
        private String name;
    }

    @Data
    @Accessors(chain = true)
    @NoArgsConstructor
    public static class Department implements Serializable, ITree<UserVO.Department> {
        @JsonProperty("departmentId")
        private Long departmentId;
        @JsonProperty("name")
        private String name;
        @JsonProperty("parentId")
        private Long parentId;
        @JsonProperty("childList")
        private List<UserVO.Department> childList;
        @Override
        public Long getId() {
            return departmentId;
        }
        @Override
        public void setChildList(List<UserVO.Department> childList) {
            this.childList = childList;
        }

    }

    @Data
    @Accessors(chain = true)
    @NoArgsConstructor
    public static class Permissions implements Serializable {
        @JsonProperty("name")
        private String name;
        @JsonProperty("chineseName")
        private String chineseName;
    }

    @Data
    @Accessors(chain = true)
    @NoArgsConstructor
    public static class Role implements Serializable {
        @JsonProperty("id")
        private String name;
        @JsonProperty("name")
        private String chineseName;
    }

}
